import React from 'react';
import { Button } from 'antd';
import './sub.less'

class Sub1 extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            num: 100
        }
    }
    // 减按钮 点击事件
    reduceBtnClick(){
        let num = this.state.num;
        num = num - 1;
        if (num <= 0) {
            num = 100;
        }
        this.setState({
            num: num 
        })
        const {reduceBtnClickCallBack} = this.props;
        reduceBtnClickCallBack(num);
        //  this.props.reduceBtnClickCallBack(num);
    }

    render() {
        return (
            <div className='sub1'>
                我是Home组件的子组件1,接收到的父组件的数据：{this.props.count}
                <div>我是接受到的兄弟组件的数据: {this.props.brotherData}</div>
                <div>
                    <Button onClick={this.reduceBtnClick.bind(this)}>减按钮{this.state.num}</Button>
                </div>
            </div>
        );
    }
    componentDidMount() {

    }
}

export default Sub1;
